<%@ page import="serverDB.*" %>
<%@ page import="java.util.Set" %>

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="JavaScript" type="text/javascript">
function ConfirmDelete(delUrl)
{
/* var answer = confirm("Do you want to delete this file?");
if(answer==true)
{
	window.location = delUrl;
} */
	document.getElementById('deleteConfirm').style.visibility = "visible";
}
</script>
<script language="JavaScript">
	var link="www.google.com";
    function toggle(open,url) {
    	link=url;
        var state = document.getElementById('deleteConfirm').style.display;
        if (state == 'block' && open==0) {
            document.getElementById('fadeDiv').style.display = 'none';
            document.getElementById('deleteConfirm').style.display = 'none';
            document.bgColor="#FFFFFF";
        } else {
            document.getElementById('fadeDiv').style.display = 'block';
            document.getElementById('deleteConfirm').style.display = 'block';
            fadein();
        }
    }
    function confirmed() {
    	window.location = link;
    }
</script>
<title>CleverDropBox</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/cufon-yui.js"></script>
<script type="text/javascript" src="js/arial.js"></script>
<script type="text/javascript" src="js/cuf_run.js"></script>

</head>
<body>
<div class="fadeDiv" id="fadeDiv"></div>
<% if(!(Boolean)session.getAttribute("logedIn")) 
	response.sendRedirect("index.jsp");
	%>
<div class="main2">
  <div class="header">
    <div class="header_resize">
      <div class="logo">
        <h1><a href="index.jsp">Clever<span>DropBox</span></a></h1>
      </div>
      <div class="menu_nav">
        <ul>
          <li><a href="index.jsp"><span>Home</span></a></li>
          <li class="active"><a href="users.jsp"><span>Users</span></a></li>
          <li><a href="support.html"><span>Support</span></a></li>
          <li><a href="aboutUs.jsp"><span>About Us</span></a></li>
          <li><a href="contactUs.jsp"><span>Contact Us</span></a></li>
        </ul>
        <div class="clr"></div>
      </div>
      <div class="clr"></div>
    </div>
  </div>
  <div class="clr"></div>
  <div class="content">
  <div class="infobar">
     <%= session.getAttribute("userName") %> &nbsp;&nbsp;&nbsp;&nbsp;
     <a href= "LogOutServlet">logout</a>
    </div>
    <div class="clr"></div>
    <div class="content_resize">
      <div class="mainbar">
		<% Set<File> files = (Set<File>)session.getAttribute("files"); %>
        <div class="article">
        
        <div class="deleteConfirm" id="deleteConfirm">
        	<center>
        	<h3>Confirm Delete</h3>
        	Are you shore you want to delete this file?<br/><br/>
        	</center>
        	<a href='#'   onclick="javascript:toggle(0,'')">
        	<img src="images/cencel.png" />
        	</a>
        	<a href='#'   onclick="javascript:confirmed()">
        	<img src="images/delete.png" />
        	</a>
        	
        	
        </div>
        	<table class="fileTable">
        		<tr>
        		<td><b>File Name</b></td>
        		<td><b>Box Name</b></td>
        		<td><b>Last modified</b></td>
				</tr>
				<% 
					int i=0;
					for(File f : files){ %>
					<tr>
						<td><%=f.getFileName() %></td>
						<td><%Box theBox = f.getBoxes().iterator().next();%>
							<%=theBox.getBoxName() %>
						</td>
						<td><%=f.getModefiedDate() %></td>
						<td><a href="downloadFile.jsp?id=<%=i%>"><img src="images/download.png" /></a></td>
						<td><a href='#'   onclick="javascript:toggle(1,'deleteFile.jsp?idFile=<%=i%>&idBox=<%=theBox.getBoxId()%>')"><img src="images/x.png" /></a></td>
					</tr>
	      		<%		i++;
	      			} %>
			</table>
        </div>
      </div>
      <div class="sidebar">
        <div class="search">
          <form id="form" name="form" method="post" action="SearchServlet">
            <span>
            <input name="search0" type="text" class="keywords" id="search" maxlength="50" value="Search..." />
            <input name="b" type="image" src="images/search.gif" class="button" />
            </span>
          </form>
        </div>
        <div class="gadget">
          <h2>Menu</h2>
          <div class="clr"></div>
          <ul class="sb_menu">
          	<li><a href="logedIn2.jsp">My Boxes</a></li>
            <li><a href="uploadFile.jsp">Upload File</a></li>
            <li><a href="advancedSearch.jsp">Advanced Search</a></li>
            <li><a href="newBox.jsp">Create New Box</a></li>
            <li><a href="shareBox.jsp">Share Box</a></li>
          </ul>
        </div>
        
        <div class="gadget">
          <h2>Wise Words</h2>
          <div class="clr"></div>
          <p> <img src="images/test_1.gif" alt="" width="19" height="20" /> <em>We can let circumstances rule us, or we can take charge and rule our lives from within </em>.<img src="images/test_2.gif" alt="" width="19" height="20" /></p>
          <p style="float:right;"><strong>Earl Nightingale</strong></p>
        </div>
      </div>

      <div class="clr"></div>
    </div>
  </div>
  <div class="fbg">
    <div class="fbg_resize">
      
      <div class="clr"></div>
    </div>
    <div class="footer">
      <p class="lf">&copy; Copyright <a href="#">MyWebSite</a>.</p>
      <p class="rf">Layout by Cool <a href="http://www.coolwebtemplates.net/">Website Templates</a></p>
      <div class="clr"></div>
    </div>
  </div>
</div>
</body>
</html>
